{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "0678c215-33c3-4cba-997d-9b9d8bc0afdf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "trade_date : <function format.<locals>.<lambda> at 0x000000000590CA60>\n",
      "vol : <function format.<locals>.<lambda> at 0x000000000585E560>\n",
      "amount : <function format.<locals>.<lambda> at 0x0000000006209990>\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ts_code</th>\n",
       "      <th>trade_date</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>pre_close</th>\n",
       "      <th>change</th>\n",
       "      <th>pct_chg</th>\n",
       "      <th>volume</th>\n",
       "      <th>amount</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211201</td>\n",
       "      <td>17.43</td>\n",
       "      <td>17.77</td>\n",
       "      <td>17.37</td>\n",
       "      <td>17.64</td>\n",
       "      <td>17.44</td>\n",
       "      <td>0.20</td>\n",
       "      <td>1.1468</td>\n",
       "      <td>706925.19</td>\n",
       "      <td>1.243667e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211202</td>\n",
       "      <td>17.62</td>\n",
       "      <td>17.81</td>\n",
       "      <td>17.37</td>\n",
       "      <td>17.59</td>\n",
       "      <td>17.64</td>\n",
       "      <td>-0.05</td>\n",
       "      <td>-0.2834</td>\n",
       "      <td>994798.35</td>\n",
       "      <td>1.749165e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211203</td>\n",
       "      <td>17.64</td>\n",
       "      <td>17.70</td>\n",
       "      <td>17.41</td>\n",
       "      <td>17.65</td>\n",
       "      <td>17.59</td>\n",
       "      <td>0.06</td>\n",
       "      <td>0.3411</td>\n",
       "      <td>707599.74</td>\n",
       "      <td>1.242375e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211206</td>\n",
       "      <td>17.85</td>\n",
       "      <td>18.56</td>\n",
       "      <td>17.80</td>\n",
       "      <td>18.10</td>\n",
       "      <td>17.65</td>\n",
       "      <td>0.45</td>\n",
       "      <td>2.5496</td>\n",
       "      <td>2145625.28</td>\n",
       "      <td>3.896385e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211207</td>\n",
       "      <td>18.30</td>\n",
       "      <td>18.67</td>\n",
       "      <td>18.15</td>\n",
       "      <td>18.46</td>\n",
       "      <td>18.10</td>\n",
       "      <td>0.36</td>\n",
       "      <td>1.9890</td>\n",
       "      <td>1616443.87</td>\n",
       "      <td>2.979969e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211208</td>\n",
       "      <td>18.45</td>\n",
       "      <td>18.55</td>\n",
       "      <td>18.16</td>\n",
       "      <td>18.47</td>\n",
       "      <td>18.46</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.0542</td>\n",
       "      <td>980281.18</td>\n",
       "      <td>1.798691e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211209</td>\n",
       "      <td>18.49</td>\n",
       "      <td>19.06</td>\n",
       "      <td>18.37</td>\n",
       "      <td>18.70</td>\n",
       "      <td>18.47</td>\n",
       "      <td>0.23</td>\n",
       "      <td>1.2453</td>\n",
       "      <td>1455886.68</td>\n",
       "      <td>2.726663e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211210</td>\n",
       "      <td>18.51</td>\n",
       "      <td>18.70</td>\n",
       "      <td>18.27</td>\n",
       "      <td>18.38</td>\n",
       "      <td>18.70</td>\n",
       "      <td>-0.32</td>\n",
       "      <td>-1.7112</td>\n",
       "      <td>989255.13</td>\n",
       "      <td>1.824077e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211213</td>\n",
       "      <td>18.47</td>\n",
       "      <td>18.88</td>\n",
       "      <td>18.18</td>\n",
       "      <td>18.27</td>\n",
       "      <td>18.38</td>\n",
       "      <td>-0.11</td>\n",
       "      <td>-0.5985</td>\n",
       "      <td>1314490.27</td>\n",
       "      <td>2.427804e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211214</td>\n",
       "      <td>18.16</td>\n",
       "      <td>18.17</td>\n",
       "      <td>17.52</td>\n",
       "      <td>17.58</td>\n",
       "      <td>18.27</td>\n",
       "      <td>-0.69</td>\n",
       "      <td>-3.7767</td>\n",
       "      <td>1937208.90</td>\n",
       "      <td>3.434156e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211215</td>\n",
       "      <td>17.51</td>\n",
       "      <td>17.66</td>\n",
       "      <td>17.40</td>\n",
       "      <td>17.55</td>\n",
       "      <td>17.58</td>\n",
       "      <td>-0.03</td>\n",
       "      <td>-0.1706</td>\n",
       "      <td>1294627.41</td>\n",
       "      <td>2.269821e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211216</td>\n",
       "      <td>17.55</td>\n",
       "      <td>17.73</td>\n",
       "      <td>17.46</td>\n",
       "      <td>17.72</td>\n",
       "      <td>17.55</td>\n",
       "      <td>0.17</td>\n",
       "      <td>0.9687</td>\n",
       "      <td>819479.51</td>\n",
       "      <td>1.445483e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211217</td>\n",
       "      <td>17.70</td>\n",
       "      <td>17.75</td>\n",
       "      <td>17.57</td>\n",
       "      <td>17.57</td>\n",
       "      <td>17.72</td>\n",
       "      <td>-0.15</td>\n",
       "      <td>-0.8465</td>\n",
       "      <td>602369.67</td>\n",
       "      <td>1.062875e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211220</td>\n",
       "      <td>17.56</td>\n",
       "      <td>17.65</td>\n",
       "      <td>17.45</td>\n",
       "      <td>17.52</td>\n",
       "      <td>17.57</td>\n",
       "      <td>-0.05</td>\n",
       "      <td>-0.2846</td>\n",
       "      <td>746435.20</td>\n",
       "      <td>1.309029e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211221</td>\n",
       "      <td>17.49</td>\n",
       "      <td>17.71</td>\n",
       "      <td>17.48</td>\n",
       "      <td>17.59</td>\n",
       "      <td>17.52</td>\n",
       "      <td>0.07</td>\n",
       "      <td>0.3995</td>\n",
       "      <td>893734.04</td>\n",
       "      <td>1.572896e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211222</td>\n",
       "      <td>17.62</td>\n",
       "      <td>17.64</td>\n",
       "      <td>17.30</td>\n",
       "      <td>17.39</td>\n",
       "      <td>17.59</td>\n",
       "      <td>-0.20</td>\n",
       "      <td>-1.1370</td>\n",
       "      <td>976927.75</td>\n",
       "      <td>1.701773e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211223</td>\n",
       "      <td>17.40</td>\n",
       "      <td>17.43</td>\n",
       "      <td>17.21</td>\n",
       "      <td>17.32</td>\n",
       "      <td>17.39</td>\n",
       "      <td>-0.07</td>\n",
       "      <td>-0.4025</td>\n",
       "      <td>1059575.94</td>\n",
       "      <td>1.831123e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211224</td>\n",
       "      <td>17.33</td>\n",
       "      <td>17.35</td>\n",
       "      <td>17.21</td>\n",
       "      <td>17.31</td>\n",
       "      <td>17.32</td>\n",
       "      <td>-0.01</td>\n",
       "      <td>-0.0577</td>\n",
       "      <td>488251.49</td>\n",
       "      <td>8.431097e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211227</td>\n",
       "      <td>17.33</td>\n",
       "      <td>17.35</td>\n",
       "      <td>17.16</td>\n",
       "      <td>17.22</td>\n",
       "      <td>17.31</td>\n",
       "      <td>-0.09</td>\n",
       "      <td>-0.5199</td>\n",
       "      <td>731118.99</td>\n",
       "      <td>1.260455e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211228</td>\n",
       "      <td>17.22</td>\n",
       "      <td>17.33</td>\n",
       "      <td>17.09</td>\n",
       "      <td>17.17</td>\n",
       "      <td>17.22</td>\n",
       "      <td>-0.05</td>\n",
       "      <td>-0.2904</td>\n",
       "      <td>1126638.91</td>\n",
       "      <td>1.934461e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211229</td>\n",
       "      <td>17.16</td>\n",
       "      <td>17.16</td>\n",
       "      <td>16.70</td>\n",
       "      <td>16.75</td>\n",
       "      <td>17.17</td>\n",
       "      <td>-0.42</td>\n",
       "      <td>-2.4461</td>\n",
       "      <td>1469373.98</td>\n",
       "      <td>2.480535e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211230</td>\n",
       "      <td>16.76</td>\n",
       "      <td>16.95</td>\n",
       "      <td>16.72</td>\n",
       "      <td>16.82</td>\n",
       "      <td>16.75</td>\n",
       "      <td>0.07</td>\n",
       "      <td>0.4179</td>\n",
       "      <td>796663.60</td>\n",
       "      <td>1.342374e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20211231</td>\n",
       "      <td>16.86</td>\n",
       "      <td>16.90</td>\n",
       "      <td>16.40</td>\n",
       "      <td>16.48</td>\n",
       "      <td>16.82</td>\n",
       "      <td>-0.34</td>\n",
       "      <td>-2.0214</td>\n",
       "      <td>1750760.89</td>\n",
       "      <td>2.899617e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211201</td>\n",
       "      <td>680.00</td>\n",
       "      <td>684.99</td>\n",
       "      <td>664.11</td>\n",
       "      <td>672.00</td>\n",
       "      <td>680.00</td>\n",
       "      <td>-8.00</td>\n",
       "      <td>-1.1765</td>\n",
       "      <td>69845.71</td>\n",
       "      <td>4.696868e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211202</td>\n",
       "      <td>671.98</td>\n",
       "      <td>689.20</td>\n",
       "      <td>669.00</td>\n",
       "      <td>688.00</td>\n",
       "      <td>672.00</td>\n",
       "      <td>16.00</td>\n",
       "      <td>2.3810</td>\n",
       "      <td>91789.56</td>\n",
       "      <td>6.268320e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211203</td>\n",
       "      <td>688.96</td>\n",
       "      <td>692.00</td>\n",
       "      <td>671.00</td>\n",
       "      <td>687.00</td>\n",
       "      <td>688.00</td>\n",
       "      <td>-1.00</td>\n",
       "      <td>-0.1453</td>\n",
       "      <td>80781.64</td>\n",
       "      <td>5.501798e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211206</td>\n",
       "      <td>676.10</td>\n",
       "      <td>680.20</td>\n",
       "      <td>656.00</td>\n",
       "      <td>657.28</td>\n",
       "      <td>687.00</td>\n",
       "      <td>-29.72</td>\n",
       "      <td>-4.3261</td>\n",
       "      <td>112612.15</td>\n",
       "      <td>7.509355e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211207</td>\n",
       "      <td>662.00</td>\n",
       "      <td>663.00</td>\n",
       "      <td>612.20</td>\n",
       "      <td>629.00</td>\n",
       "      <td>657.28</td>\n",
       "      <td>-28.28</td>\n",
       "      <td>-4.3026</td>\n",
       "      <td>221391.47</td>\n",
       "      <td>1.391343e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211208</td>\n",
       "      <td>634.79</td>\n",
       "      <td>644.78</td>\n",
       "      <td>626.25</td>\n",
       "      <td>639.00</td>\n",
       "      <td>629.00</td>\n",
       "      <td>10.00</td>\n",
       "      <td>1.5898</td>\n",
       "      <td>118866.02</td>\n",
       "      <td>7.580712e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211209</td>\n",
       "      <td>639.00</td>\n",
       "      <td>640.00</td>\n",
       "      <td>622.90</td>\n",
       "      <td>633.80</td>\n",
       "      <td>639.00</td>\n",
       "      <td>-5.20</td>\n",
       "      <td>-0.8138</td>\n",
       "      <td>134272.09</td>\n",
       "      <td>8.443913e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211210</td>\n",
       "      <td>622.22</td>\n",
       "      <td>653.36</td>\n",
       "      <td>621.18</td>\n",
       "      <td>639.95</td>\n",
       "      <td>633.80</td>\n",
       "      <td>6.15</td>\n",
       "      <td>0.9703</td>\n",
       "      <td>213844.18</td>\n",
       "      <td>1.373824e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211213</td>\n",
       "      <td>639.90</td>\n",
       "      <td>660.66</td>\n",
       "      <td>630.08</td>\n",
       "      <td>658.36</td>\n",
       "      <td>639.95</td>\n",
       "      <td>18.41</td>\n",
       "      <td>2.8768</td>\n",
       "      <td>160827.78</td>\n",
       "      <td>1.040979e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211214</td>\n",
       "      <td>657.34</td>\n",
       "      <td>657.34</td>\n",
       "      <td>643.98</td>\n",
       "      <td>651.01</td>\n",
       "      <td>658.36</td>\n",
       "      <td>-7.35</td>\n",
       "      <td>-1.1164</td>\n",
       "      <td>87810.80</td>\n",
       "      <td>5.704000e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211215</td>\n",
       "      <td>649.43</td>\n",
       "      <td>661.00</td>\n",
       "      <td>646.95</td>\n",
       "      <td>649.00</td>\n",
       "      <td>651.01</td>\n",
       "      <td>-2.01</td>\n",
       "      <td>-0.3088</td>\n",
       "      <td>70480.16</td>\n",
       "      <td>4.606545e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211216</td>\n",
       "      <td>657.30</td>\n",
       "      <td>657.30</td>\n",
       "      <td>647.08</td>\n",
       "      <td>655.06</td>\n",
       "      <td>649.00</td>\n",
       "      <td>6.06</td>\n",
       "      <td>0.9337</td>\n",
       "      <td>61502.22</td>\n",
       "      <td>4.018261e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211217</td>\n",
       "      <td>651.01</td>\n",
       "      <td>653.99</td>\n",
       "      <td>639.70</td>\n",
       "      <td>651.19</td>\n",
       "      <td>655.06</td>\n",
       "      <td>-3.87</td>\n",
       "      <td>-0.5908</td>\n",
       "      <td>136490.81</td>\n",
       "      <td>8.863378e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211220</td>\n",
       "      <td>649.00</td>\n",
       "      <td>649.00</td>\n",
       "      <td>607.68</td>\n",
       "      <td>610.21</td>\n",
       "      <td>651.19</td>\n",
       "      <td>-40.98</td>\n",
       "      <td>-6.2931</td>\n",
       "      <td>155113.52</td>\n",
       "      <td>9.648533e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211221</td>\n",
       "      <td>606.00</td>\n",
       "      <td>614.69</td>\n",
       "      <td>594.08</td>\n",
       "      <td>604.07</td>\n",
       "      <td>610.21</td>\n",
       "      <td>-6.14</td>\n",
       "      <td>-1.0062</td>\n",
       "      <td>125657.80</td>\n",
       "      <td>7.553655e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211222</td>\n",
       "      <td>608.80</td>\n",
       "      <td>617.00</td>\n",
       "      <td>603.00</td>\n",
       "      <td>610.24</td>\n",
       "      <td>604.07</td>\n",
       "      <td>6.17</td>\n",
       "      <td>1.0214</td>\n",
       "      <td>83618.40</td>\n",
       "      <td>5.103433e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211223</td>\n",
       "      <td>618.98</td>\n",
       "      <td>630.80</td>\n",
       "      <td>612.08</td>\n",
       "      <td>622.07</td>\n",
       "      <td>610.24</td>\n",
       "      <td>11.83</td>\n",
       "      <td>1.9386</td>\n",
       "      <td>79718.19</td>\n",
       "      <td>4.954755e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211224</td>\n",
       "      <td>624.00</td>\n",
       "      <td>625.25</td>\n",
       "      <td>563.00</td>\n",
       "      <td>576.80</td>\n",
       "      <td>622.07</td>\n",
       "      <td>-45.27</td>\n",
       "      <td>-7.2773</td>\n",
       "      <td>246080.84</td>\n",
       "      <td>1.432130e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211227</td>\n",
       "      <td>574.20</td>\n",
       "      <td>587.99</td>\n",
       "      <td>573.50</td>\n",
       "      <td>578.60</td>\n",
       "      <td>576.80</td>\n",
       "      <td>1.80</td>\n",
       "      <td>0.3121</td>\n",
       "      <td>101835.43</td>\n",
       "      <td>5.915820e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211228</td>\n",
       "      <td>578.00</td>\n",
       "      <td>587.28</td>\n",
       "      <td>569.91</td>\n",
       "      <td>585.00</td>\n",
       "      <td>578.60</td>\n",
       "      <td>6.40</td>\n",
       "      <td>1.1061</td>\n",
       "      <td>96595.74</td>\n",
       "      <td>5.589310e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211229</td>\n",
       "      <td>585.00</td>\n",
       "      <td>585.99</td>\n",
       "      <td>569.78</td>\n",
       "      <td>575.55</td>\n",
       "      <td>585.00</td>\n",
       "      <td>-9.45</td>\n",
       "      <td>-1.6154</td>\n",
       "      <td>99639.63</td>\n",
       "      <td>5.731323e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211230</td>\n",
       "      <td>577.00</td>\n",
       "      <td>596.29</td>\n",
       "      <td>575.57</td>\n",
       "      <td>590.00</td>\n",
       "      <td>575.55</td>\n",
       "      <td>14.45</td>\n",
       "      <td>2.5106</td>\n",
       "      <td>124209.46</td>\n",
       "      <td>7.323089e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>300750.SZ</td>\n",
       "      <td>20211231</td>\n",
       "      <td>598.30</td>\n",
       "      <td>605.99</td>\n",
       "      <td>582.00</td>\n",
       "      <td>588.00</td>\n",
       "      <td>590.00</td>\n",
       "      <td>-2.00</td>\n",
       "      <td>-0.3390</td>\n",
       "      <td>93711.17</td>\n",
       "      <td>5.540409e+06</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      ts_code trade_date    open    high     low   close  pre_close  change  \\\n",
       "22  000001.SZ   20211201   17.43   17.77   17.37   17.64      17.44    0.20   \n",
       "21  000001.SZ   20211202   17.62   17.81   17.37   17.59      17.64   -0.05   \n",
       "20  000001.SZ   20211203   17.64   17.70   17.41   17.65      17.59    0.06   \n",
       "19  000001.SZ   20211206   17.85   18.56   17.80   18.10      17.65    0.45   \n",
       "18  000001.SZ   20211207   18.30   18.67   18.15   18.46      18.10    0.36   \n",
       "17  000001.SZ   20211208   18.45   18.55   18.16   18.47      18.46    0.01   \n",
       "16  000001.SZ   20211209   18.49   19.06   18.37   18.70      18.47    0.23   \n",
       "15  000001.SZ   20211210   18.51   18.70   18.27   18.38      18.70   -0.32   \n",
       "14  000001.SZ   20211213   18.47   18.88   18.18   18.27      18.38   -0.11   \n",
       "13  000001.SZ   20211214   18.16   18.17   17.52   17.58      18.27   -0.69   \n",
       "12  000001.SZ   20211215   17.51   17.66   17.40   17.55      17.58   -0.03   \n",
       "11  000001.SZ   20211216   17.55   17.73   17.46   17.72      17.55    0.17   \n",
       "10  000001.SZ   20211217   17.70   17.75   17.57   17.57      17.72   -0.15   \n",
       "9   000001.SZ   20211220   17.56   17.65   17.45   17.52      17.57   -0.05   \n",
       "8   000001.SZ   20211221   17.49   17.71   17.48   17.59      17.52    0.07   \n",
       "7   000001.SZ   20211222   17.62   17.64   17.30   17.39      17.59   -0.20   \n",
       "6   000001.SZ   20211223   17.40   17.43   17.21   17.32      17.39   -0.07   \n",
       "5   000001.SZ   20211224   17.33   17.35   17.21   17.31      17.32   -0.01   \n",
       "4   000001.SZ   20211227   17.33   17.35   17.16   17.22      17.31   -0.09   \n",
       "3   000001.SZ   20211228   17.22   17.33   17.09   17.17      17.22   -0.05   \n",
       "2   000001.SZ   20211229   17.16   17.16   16.70   16.75      17.17   -0.42   \n",
       "1   000001.SZ   20211230   16.76   16.95   16.72   16.82      16.75    0.07   \n",
       "0   000001.SZ   20211231   16.86   16.90   16.40   16.48      16.82   -0.34   \n",
       "22  300750.SZ   20211201  680.00  684.99  664.11  672.00     680.00   -8.00   \n",
       "21  300750.SZ   20211202  671.98  689.20  669.00  688.00     672.00   16.00   \n",
       "20  300750.SZ   20211203  688.96  692.00  671.00  687.00     688.00   -1.00   \n",
       "19  300750.SZ   20211206  676.10  680.20  656.00  657.28     687.00  -29.72   \n",
       "18  300750.SZ   20211207  662.00  663.00  612.20  629.00     657.28  -28.28   \n",
       "17  300750.SZ   20211208  634.79  644.78  626.25  639.00     629.00   10.00   \n",
       "16  300750.SZ   20211209  639.00  640.00  622.90  633.80     639.00   -5.20   \n",
       "15  300750.SZ   20211210  622.22  653.36  621.18  639.95     633.80    6.15   \n",
       "14  300750.SZ   20211213  639.90  660.66  630.08  658.36     639.95   18.41   \n",
       "13  300750.SZ   20211214  657.34  657.34  643.98  651.01     658.36   -7.35   \n",
       "12  300750.SZ   20211215  649.43  661.00  646.95  649.00     651.01   -2.01   \n",
       "11  300750.SZ   20211216  657.30  657.30  647.08  655.06     649.00    6.06   \n",
       "10  300750.SZ   20211217  651.01  653.99  639.70  651.19     655.06   -3.87   \n",
       "9   300750.SZ   20211220  649.00  649.00  607.68  610.21     651.19  -40.98   \n",
       "8   300750.SZ   20211221  606.00  614.69  594.08  604.07     610.21   -6.14   \n",
       "7   300750.SZ   20211222  608.80  617.00  603.00  610.24     604.07    6.17   \n",
       "6   300750.SZ   20211223  618.98  630.80  612.08  622.07     610.24   11.83   \n",
       "5   300750.SZ   20211224  624.00  625.25  563.00  576.80     622.07  -45.27   \n",
       "4   300750.SZ   20211227  574.20  587.99  573.50  578.60     576.80    1.80   \n",
       "3   300750.SZ   20211228  578.00  587.28  569.91  585.00     578.60    6.40   \n",
       "2   300750.SZ   20211229  585.00  585.99  569.78  575.55     585.00   -9.45   \n",
       "1   300750.SZ   20211230  577.00  596.29  575.57  590.00     575.55   14.45   \n",
       "0   300750.SZ   20211231  598.30  605.99  582.00  588.00     590.00   -2.00   \n",
       "\n",
       "    pct_chg      volume        amount  \n",
       "22   1.1468   706925.19  1.243667e+06  \n",
       "21  -0.2834   994798.35  1.749165e+06  \n",
       "20   0.3411   707599.74  1.242375e+06  \n",
       "19   2.5496  2145625.28  3.896385e+06  \n",
       "18   1.9890  1616443.87  2.979969e+06  \n",
       "17   0.0542   980281.18  1.798691e+06  \n",
       "16   1.2453  1455886.68  2.726663e+06  \n",
       "15  -1.7112   989255.13  1.824077e+06  \n",
       "14  -0.5985  1314490.27  2.427804e+06  \n",
       "13  -3.7767  1937208.90  3.434156e+06  \n",
       "12  -0.1706  1294627.41  2.269821e+06  \n",
       "11   0.9687   819479.51  1.445483e+06  \n",
       "10  -0.8465   602369.67  1.062875e+06  \n",
       "9   -0.2846   746435.20  1.309029e+06  \n",
       "8    0.3995   893734.04  1.572896e+06  \n",
       "7   -1.1370   976927.75  1.701773e+06  \n",
       "6   -0.4025  1059575.94  1.831123e+06  \n",
       "5   -0.0577   488251.49  8.431097e+05  \n",
       "4   -0.5199   731118.99  1.260455e+06  \n",
       "3   -0.2904  1126638.91  1.934461e+06  \n",
       "2   -2.4461  1469373.98  2.480535e+06  \n",
       "1    0.4179   796663.60  1.342374e+06  \n",
       "0   -2.0214  1750760.89  2.899617e+06  \n",
       "22  -1.1765    69845.71  4.696868e+06  \n",
       "21   2.3810    91789.56  6.268320e+06  \n",
       "20  -0.1453    80781.64  5.501798e+06  \n",
       "19  -4.3261   112612.15  7.509355e+06  \n",
       "18  -4.3026   221391.47  1.391343e+07  \n",
       "17   1.5898   118866.02  7.580712e+06  \n",
       "16  -0.8138   134272.09  8.443913e+06  \n",
       "15   0.9703   213844.18  1.373824e+07  \n",
       "14   2.8768   160827.78  1.040979e+07  \n",
       "13  -1.1164    87810.80  5.704000e+06  \n",
       "12  -0.3088    70480.16  4.606545e+06  \n",
       "11   0.9337    61502.22  4.018261e+06  \n",
       "10  -0.5908   136490.81  8.863378e+06  \n",
       "9   -6.2931   155113.52  9.648533e+06  \n",
       "8   -1.0062   125657.80  7.553655e+06  \n",
       "7    1.0214    83618.40  5.103433e+06  \n",
       "6    1.9386    79718.19  4.954755e+06  \n",
       "5   -7.2773   246080.84  1.432130e+07  \n",
       "4    0.3121   101835.43  5.915820e+06  \n",
       "3    1.1061    96595.74  5.589310e+06  \n",
       "2   -1.6154    99639.63  5.731323e+06  \n",
       "1    2.5106   124209.46  7.323089e+06  \n",
       "0   -0.3390    93711.17  5.540409e+06  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "def getStocksTradingDays(*symbols, startDate, endDate):\n",
    "    tradedays = []\n",
    "    pro = ts.pro_api();\n",
    "    for stock_code in symbols:\n",
    "        tradedays.append(pro.daily(ts_code = stock_code, start_date = startDate, end_date = endDate))\n",
    "    return pd.concat(tradedays)\n",
    "\n",
    "def format(df):\n",
    "    formats = {}\n",
    "    formats['trade_date'] = lambda column: pd.to_datetime(df[column])\n",
    "    formats['vol'] = lambda column: (df[column] * 100, df.rename(columns = {column: 'volume'}, inplace = True))\n",
    "    formats['amount'] = lambda column: df[column] * 10000\n",
    "    for key, value in formats.items():\n",
    "        print(f'{key} : {value}')\n",
    "        result = value(key)\n",
    "        if result is None: \n",
    "            if isinstance(result, tuple):\n",
    "                df.loc[:, key] = result[0]\n",
    "                df.rename(columns={key: result[1]}, inplace=True)\n",
    "            else:\n",
    "                df[key] = reslut\n",
    "    return df.sort_values(by = ['ts_code','trade_date'], ascending = [True, True])\n",
    "data = getStocksTradingDays('300750.SZ','000001.SZ',startDate = '20211201',endDate = '20211231')\n",
    "format(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "718b3938-1f70-434d-a089-963fac28a424",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
